package com.ego.member.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ego.common.util.PageUtil;
import com.ego.common.vo.PageVo;
import com.ego.member.vo.MemberLevelSearchVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ego.member.dao.MemberLevelDao;
import com.ego.member.po.MemberLevel;
import com.ego.member.service.MemberLevelService;

/**
 * @program: ego
 * @description 会员等级对应实现类
 * @author KamTang
 * @date 2022-11-13 13:28:12
 */
@Service("memberLevelService")
public class MemberLevelServiceImpl extends ServiceImpl<MemberLevelDao, MemberLevel> implements MemberLevelService {

    @Override
    public PageVo<MemberLevel> search(MemberLevelSearchVo search) {
        LambdaQueryWrapper<MemberLevel> query = Wrappers.<MemberLevel>lambdaQuery()
                .like(StringUtils.isNotEmpty(search.getKeyword()), MemberLevel::getName, search.getKeyword())
                .or().like(StringUtils.isNotEmpty(search.getKeyword()), MemberLevel::getNote, search.getKeyword());
        Page<MemberLevel> page = this.baseMapper.selectPage(Page.of(search.getPageNum(), search.getPageSize()), query);
        return PageUtil.toPage(page);
    }
}
